package de.westranger.forex.trading.analysis;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.text.ParseException;

import de.westranger.forex.trading.genetic.allel.ChromosomPrinter;
import de.westranger.forex.trading.genetic.allel.chromosom.CompositeChromosom;
import de.westranger.forex.trading.genetic.allel.operator.UnknownOperatorException;

public class OutputChromosom2GraphVIZ {

	private static final String OUTPUT = ".\\out\\wk8_3_result.ser";

	/**
	 * @param args
	 * @throws ParseException 
	 * @throws IOException 
	 * @throws UnknownOperatorException 
	 */
	public static void main(String[] args) throws IOException, ParseException, UnknownOperatorException {
		CompositeChromosom in = null;
		try{
			FileInputStream fis = new FileInputStream(OUTPUT);
		    ObjectInputStream ois = new ObjectInputStream(fis);
		    in = (CompositeChromosom) ois.readObject();
		    ois.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		
		final ChromosomPrinter chromPrint = new ChromosomPrinter();

		FileWriter fw = new FileWriter("./out/omni_sell.txt");
		fw.append(chromPrint.generateGraphVIZ(((CompositeChromosom)in).getNodeSell()));
		fw.close();
		fw = new FileWriter("./out/omni_buy.txt");
		fw.append(chromPrint.generateGraphVIZ(((CompositeChromosom)in).getNodeBuy()));
		fw.close();
	}
}
